package com.ruoyi.punishment.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.punishment.mapper.FirefighterPunishmentMapper;
import com.ruoyi.punishment.domain.FirefighterPunishment;
import com.ruoyi.punishment.service.IFirefighterPunishmentService;

/**
 * 处分情况Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class FirefighterPunishmentServiceImpl implements IFirefighterPunishmentService
{
    @Autowired
    private FirefighterPunishmentMapper firefighterPunishmentMapper;
    @Autowired
    private IFirefighterInfoService iFirefighterInfoService;
    /**
     * 查询处分情况
     *
     * @param id 处分情况主键
     * @return 处分情况
     */
    @Override
    public FirefighterPunishment selectFirefighterPunishmentById(Long id)
    {
        return firefighterPunishmentMapper.selectFirefighterPunishmentById(id);
    }

    /**
     * 查询处分情况列表
     *
     * @param firefighterPunishment 处分情况
     * @return 处分情况
     */
    @Override
    public List<FirefighterPunishment> selectFirefighterPunishmentList(FirefighterPunishment firefighterPunishment)
    {
        return firefighterPunishmentMapper.selectFirefighterPunishmentList(firefighterPunishment);
    }

    /**
     * 新增处分情况
     *
     * @param firefighterPunishment 处分情况
     * @return 结果
     */
    @Override
    public int insertFirefighterPunishment(FirefighterPunishment firefighterPunishment)
    {
        FirefighterInfo firefighterInfo1 = new FirefighterInfo();
        firefighterInfo1.setIdCardNumber(firefighterPunishment.getFirefighterIdCard());
        FirefighterInfo firefighterInfo= iFirefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo1);
        firefighterPunishment.setFirefighterId(firefighterInfo.getUserId());
        firefighterPunishment.setCreateTime(DateUtils.getNowDate());
        return firefighterPunishmentMapper.insertFirefighterPunishment(firefighterPunishment);
    }

    /**
     * 修改处分情况
     *
     * @param firefighterPunishment 处分情况
     * @return 结果
     */
    @Override
    public int updateFirefighterPunishment(FirefighterPunishment firefighterPunishment)
    {
        firefighterPunishment.setUpdateTime(DateUtils.getNowDate());
        return firefighterPunishmentMapper.updateFirefighterPunishment(firefighterPunishment);
    }

    /**
     * 批量删除处分情况
     *
     * @param ids 需要删除的处分情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterPunishmentByIds(Long[] ids)
    {
        return firefighterPunishmentMapper.deleteFirefighterPunishmentByIds(ids);
    }

    /**
     * 删除处分情况信息
     *
     * @param id 处分情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterPunishmentById(Long id)
    {
        return firefighterPunishmentMapper.deleteFirefighterPunishmentById(id);
    }

    @Override
    public void deleteFirefighterPunishmentById1(Long userId) {
        firefighterPunishmentMapper.deleteFirefighterPunishmentByIdsuser(userId);
    }
}
